package com.framework.jqgrid;


public class JqGridPager {
    private String id;//行id
    private int pager;//当前页数
    private int total;//总页数
    private String records;//总共的数据
    private int rows;//包含实际数据的数组
    private String pgButton;//翻页动作first,last,prev,next
    private String sord;//排序类别
    private String sidx;//排序字段
    private int startRow; //当前页在数据库中的起始行
    private String where;//查询条件
    private String isexport;//是否导出查询
    private String exportCol;//定义导出字段
    private String exporttype;//导出类型
    private String expselectcol;//导出数据查询字段

    public JqGridPager(String id_, int pager_, int total_, String records_, int rows_, String pgButton_, String sord_, String sidx_) {
        id = id_;
        pager = pager_;
        total = total_;
        records = records_;
        rows = rows_;
        pgButton = pgButton_;
        sord = sord_;
        sidx = sidx_;
    }

    public JqGridPager() {
    }

    public void setRecords(String records) {
        this.records = records;
        if (Integer.valueOf(records) % rows > 0) {
            setTotal(Integer.valueOf(records) / rows + 1);
        } else {
            setTotal(Integer.valueOf(records) / rows);
        }

    }

    public void setPage() {
        if (pgButton != null) {
            if (pgButton.equals("next")) {//下一页
                if (pager < total) {
                    pager++;
                }
                startRow = (pager - 1) * rows;
            } else if (pgButton.equals("prev")) {//上一页
                if (pager == 0) {
                } else {
                    startRow = (pager - 1) * rows;
                }
            } else if (pgButton.equals("last")) {//最后一页
                //pager = total;
                startRow = (pager - 1) * rows;
            } else if (pgButton.equals("first")) {//第一页
                pager = 1;
                startRow = 0;
            } else if (pager > 1) {
                //pager = 1;
                startRow = (pager - 1) * rows;
            } else {
                pager = 1;
                startRow = 0;
            }
        } else {
            pager = 1;
            startRow = 0;
        }
    }

    //public String getRecordsSql(String sql){
//}
    public String getSord() {
        return sord;
    }

    public void setSord(String sord) {
        this.sord = sord;
    }

    public String getSidx() {
        return sidx;
    }

    public void setSidx(String sidx) {
        this.sidx = sidx;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        this.rows = rows;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getStartRow() {
        return startRow;
    }

    public void setStartRow(int startRow) {
        this.startRow = startRow;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getPager() {
        return pager;
    }

    public void setPager(int pager) {
        this.pager = pager;
    }

    public String getPgButton() {
        return pgButton;
    }

    public void setPgButton(String pgButton) {
        this.pgButton = pgButton;
    }

    public String getRecords() {
        return records;
    }

    public String getWhere() {
        return where;
    }

    public void setWhere(String where) {
        this.where = where;
    }

    public String getExportCol() {
        return exportCol;
    }

    public void setExportCol(String exportCol) {
        this.exportCol = exportCol;
    }

    public String getExporttype() {
        return exporttype;
    }

    public void setExporttype(String exporttype) {
        this.exporttype = exporttype;
    }

    public String getExpselectcol() {
        return expselectcol;
    }

    public void setExpselectcol(String expselectcol) {
        this.expselectcol = expselectcol;
    }

    public String getIsexport() {
        return isexport;
    }

    public void setIsexport(String isexport) {
        this.isexport = isexport;
    }

}
